#pragma once

#include "Framework.hpp"

class ProgramConfig
{
public:
	ProgramConfig();
	~ProgramConfig();
	
	bool Load(HINSTANCE Instance, const char *CmdLine);

	const frame::SETTINGS & GetFrameworkSettings() { return m_FrameworkSettings; }
	bool GetLogConsole() { return m_LogConsole; }
	bool GetLogFile()    { return m_LogFile;    }

private:
	enum FIELD
	{
		FIELD_RESX         = 0x00000001,
		FIELD_RESY         = 0x00000002,
		FIELD_REFRESH_RATE = 0x00000004,
		FIELD_ALL = FIELD_RESX | FIELD_RESY | FIELD_REFRESH_RATE,
	};

	frame::SETTINGS m_FrameworkSettings;
	bool m_LogConsole, m_LogFile;
	// Bit flags telling which mandatory fields have been set.
	unsigned m_FieldSetFlags;
	HINSTANCE m_Instance;

	// Returns false if error.
	bool ParseCommandLine(const char *CmdLine);
	void ErrorMessage(const string &Msg);
	bool AllMandatoryFieldsSet() { return m_FieldSetFlags == FIELD_ALL; }
	// On error: shows error message and returns false.
	bool LoadConfigFile(const string &FileName);
	bool ShowConfigDialog();
};

extern ProgramConfig *g_ProgramConfig;

/*
This module does not throw exceptions to the outside.
Instead, it shows MessageBox with error message.
*/
